package com.qinghe.pro;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Constants {

	public final static String LOG_ARGUMENTS = "log_arguments";// 日志参数

	public final static Integer COLUMN_TYPE_SLIDER = 2;// 幻灯片

	public final static Integer COLUMN_TYPE_RIGHT = 3;// 右侧新闻

	public final static long CACHE_EXPIRE = 3600 * 24L;// 缓存的失效时间:1天

	public static final String CONF_FILE_PATH = "properties/config.properties";

	private static Properties prop = new Properties();

	public static String getTempPath(){
		return prop.getProperty("temp_path");
	}

	public static String getImagePath(){
		return prop.getProperty("image_path");
	}

	public static String getXheditorPath(){
		return prop.getProperty("xheditor_path");
	}

	public static String getApiPath(){
		return prop.getProperty("api_path");
	}

	public static void load() {
		Logger log = Logger.getLogger(Constants.class);
		ClassLoader loader = Constants.class.getClassLoader();
		InputStream in = loader.getResourceAsStream(CONF_FILE_PATH);
		if (in != null) {
			try {
				prop.load(in);
			} catch (IOException e) {
				log.error("fail to load config.poperties", e);
			}
		} else {
			log.error("cant find file in classpath [config.properties]");
		}
	}

}
